<?php
class photo_block extends SClass {

    public function process() {
        $photoAlbum = Triumph::Get()->getMediaService()->getPhotoAlbumAll();
        //$photoAlbum->setMain(1);
        $photoAlbum->setLimitCount(5);
        $a = array();
        $i = 0;
        while ($x = $photoAlbum->getNext()) {
            $i++;
            $properties = $this->_makeImgProperties($i);
            $a[] = array(
                'id' => $x->getId(),
                'name' => $x->getName(),
                'image' => $x->makeImageThumb($properties['width'],$properties['height'], 'crop'),
                'url' => Engine::GetLinkMaker()->makeURLByContentIDParam('photo-view', $x->getId())
            );
        }
        $this->setValue('photoAlbumArray', $a);
    }

    /**
     * Получить нужые размеры картинки для порядка альбома
     * @param $i
     * @return array
     */
    private function _makeImgProperties ($i) {
        $a = array();
        $w = 150;
        $h = 150;
        switch ($i) {
            case 1:
                $w = 400;
                $h = 350;
                break;
            case 2:
                $w = 320;
                $h = 230;
                break;
            case 3:
                $w = 159;
                $h = 118;
                break;
            case 4:
                $w = 159;
                $h = 118;
                break;
        }
        $a['width'] = $w;
        $a['height'] = $h;
        return $a;
    }

}